package cn.ymjr.sys.config.jackson;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * 使用注解的方式对String 类型的转化为json格式进行转化输出
 *
 * Created by xinchao on 2017/1/4 0004.
 */
public class JacksonStringSerializer extends JsonSerializer<Long>{
    @Override
    public void serialize(Long value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException {
        try {
            gen.writeString(String.valueOf(value));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
